Avorion Script API Documentation

ShipDatabaseEntry [Server]

This represents an interface to a database entry of a ship of a Player or Alliance (=ShipOwner). When writing values here, proceed with caution and note that many database entries that linked directly to the ship will be overridden steadily (when changed on the ship) while it's being simulated in a sector. It only makes sense to update these values if the ship is in background simulation, and you want to change properties of the ship.
Note: Changing the name or faction properties of the instance will make the instance point to another faction/ship of that faction. It will not change the faction or name of the ship. If you want to change the ship's name, use the setNewName() function. Changing the ship's faction is not possible with this.

This object is only available on the server.

function ShipDatabaseEntry(int faction, string name)

Returns

A new instance of ShipDatabaseEntry

property int faction
property string name
property int numBlocks[read-only]

function var addScript(string path)

Adds a script to the entity. For technical reasons, it's not possible to pass initialization values here. The script will be attached as if it was restored from database, so a call to initialize() won't have any parameters and _restoring will be set to true.

Returns

nothing

function var addScriptOnce(string path)

Adds a script to the entity, if a script with the same name is not yet already attached. For technical reasons, it's not possible to pass initialization values here. The script will be attached as if it was restored from database, so a call to initialize() won't have any parameters and _restoring will be set to true.

Returns

nothing

function Crew buildIdealCrew()

function bool exists()

function ShipAvailability getAvailability()

function Captain getCaptain()

function table<TradingGood, float>, float getCargo()

Returns the current cargo and the cargo bay size. The cargo is stored in a table of the format result = { }; result[good1] = 5; result[good2] = 4; ... etc. The goods are used as keys, the amount of the good is the value.

Returns

returns 2 values: 1. A table holding the current cargo of the ship; 2. a number containing the cargo bay size of the ship

function int, int getCoordinates()

function Crew getCrew()

function bool getCrewRequirementsFulfilled()

Returns a boolean whether the crew requirements of the craft are all fulfilled. These are things like overpopulation, not enough crew members, etc.

Returns

A boolean whether the crew requirements of the ship are all fulfilled.

function var getDocksEnabled()

Returns information about the crafts's docks. If in transport mode, docks are disabled. Only valid for stations.

Returns

A bool value indicating whether docks are enabled or not

function double, double getDPSValues()

Returns information about the ship's DPS.

Returns

2 values: Total turret DPS; Total fighter DPS

function var... getDurabilityProperties()

Returns information about the ship's hull durability. Returns 5 values: The maximum durability, the durability percentage, range 0 to 1; The HP malus factor (from boarding or reconstruction), 0 to 1; A MalusReason enum value, the reason for the malus; A bool indicating if the ship is currently damaged (blocks are lost)

Returns

5 values: Maximum durability; durability percentage; malus factor; malus reason, damaged

function var... getEnergyProperties()

Returns the energy properties of the craft.

Returns

Two values: required energy, produced energy in watts

function int getEntityType()

function bool getFighterSquadRequirementsFulfilled()

Returns a boolean whether the figher squad requirements of the craft are all fulfilled. That's not fulfilled when there aren't enough squads for fighters.

Returns

A boolean whether the requirements are all fulfilled.

function bool getFighterStartRequirementsFulfilled()

Returns a boolean whether the figher start requirements of the craft are all fulfilled. That's not fulfilled when there aren't any starting positions for fighters.

Returns

A boolean whether the requirements are all fulfilled.

function float getFreeCargoSpace()

Returns the amount of free cargo space on the ship.

Returns

A number value containing the free cargo bay space of the ship

function table<unsigned int, Squad>, table_t getHangar()

Returns the current hangar squads and misc info about the hangar. The squads are stored in a table of the format squads = {}; squads[index1] = squad1; squads[index2] = squad2; ... etc. The squad indices are used as keys, the value is a Squad class. The second value is information about the hangar, with a few properties such as its space, occupied space, etc. It's recommended to use printTable() to print the complete table for inspection.

Returns

returns 2 values: 1. A table holding the current squads of the ship; 2. a table containing more hangar info

function var... getHyperspaceProperties()

Returns the hyperspace range, if the ship can pass over rifts, hyperspace cooldown and if the hyperspace engine is currently impaired (blocked or distorted by enemies) .

Returns

returns 4 values: 1. A number containing the hyperspace range of the ship; 2. A boolean whether the ship can jump over rifts; 3. The hyperspace cooldown in seconds of the ship; 4. A boolean whether the hyperspace engine is currently impaired

function string getIcon()

function table<unsigned int, Squad>, table_t getLightweightHangar()

Returns the current hangar squads and misc info about the hangar. Lightweight version that will not return BlockPlans of fighters. The squads are stored in a table of the format squads = {}; squads[index1] = squad1; squads[index2] = squad2; ... etc. The squad indices are used as keys, the value is a Squad class. The second value is information about the hangar, with a few properties such as its space, occupied space, etc. It's recommended to use printTable() to print the complete table for inspection.

Returns

returns 2 values: 1. A table holding the current squads of the ship; 2. a table containing more hangar info

function Matrix getLocalPosition()

function string getOrderInfo()

function float getPaymentTime()

function BlockPlan getPlan()

function double getPlanValue()

function var getPlayerPiloted()

Returns whether the craft is currently being piloted by a player.

Returns

A bool value whether the craft is currently being piloted by a player.

function double getReconstructionValue()

function table<int, string> getScripts()

Returns the scripts that are currently attached to the ship, in the form of a table with key = scriptIndex, value = scriptPath.

Returns

A table containing script paths by script index

function var getScriptValue(string key)

Retrieves a custom value

Parameters

key the name of the value as a string

Returns

The value

function var getScriptValues()

Returns the script values of the ship. These are the values that can be set via the setValue() and getValue() functions.

Returns

A table containing the script values by name

function var getSecuredScriptValues()

Returns the secured values of all scripts attached to the ship. Contains a table per script. This table is the one that's passed to the script in the "restore(values)" function.

Returns

A table containing value tables by script index

function float, float getShields()

Returns the max shields and percentage of the shields of the craft.

Returns

2 number values: 1. The maximum shields, 2. the percentage of the craft's shield, range 0 to 1

function NamedFormat getStatusMessage()

function pair... getSystems()

Returns the currently equipped subsystems of the ship. The subsystems are stored in a table of the format subsystems = {}; subsystems[subsystem1] = {...}; subsystems[subsystem2] = {...}; ... etc. The keys of the returned table are the subsystems, the values are information about the subsystems. It's recommended to use printTable() to print the tables for inspection.

Returns

returns a table where the subsystems are the keys, and tables holding information about the subsystems are the values

function Format getTitle()

function TorpedoTemplate... getTorpedoes()

Returns the current torpedo shafts and misc info about the torpedo launcher. The shafts are stored in a table of the format shafts = {}; shafts[index1] = shaft1; shafts[index2] = shaft2; ... etc. The shaft indices are used as keys, the value is a TorpedoShaft class. Shaft with index -1 is the general torpedo storage. Note that the space for the shafts is an integer number of torpedoes, while the space for the general storage is torpedo space, which torpedoes take up and which can be extended with blocks. The second value is information about the launcher, with a few properties such as its space, occupied space, etc. It's recommended to use printTable() to print the complete table for inspection.

Returns

returns 2 values: 1. A table holding the current shafts of the ship; 2. a table containing more launcher info

function pair... getTurrets()

Returns the currently equipped turrets of the ship. The turrets are stored in a table of the format turrets = {}; turrets[turret1] = {...}; turrets[turret2] = {...}; ... etc. The keys of the returned table are the turrets, the values are information about the turrets. It's recommended to use printTable() to print the tables for inspection.

Returns

returns a table where the turrets are the keys, and tables holding information about the turrets are the values

function bool getTurretSlotRequirementsFulfilled()

Returns a boolean whether the turret slot requirements of the craft are all fulfilled. That's not fulfilled when there aren't enough slots for all turrets.

Returns

A boolean whether the requirements are all fulfilled.

function var removeScript(var script)

Removes a script from the entity.

Parameters

script A path (fragment) or index of the script that should be removed.

Returns

nothing

function var setAvailability(ShipAvailability availability)

Returns

nothing

function var setCaptain(Captain captain)

Returns

nothing

function var setCargo(table_t cargo)

Returns

nothing

function var setCoordinates(int x, int y)

Returns

nothing

function var setCrew(Crew other)

Returns

nothing

function var setDurabilityMalus(float malusFactor, DurabilityMalusReason reason)

Returns

nothing

function var setDurabilityPercentage(float percentage)

Returns

nothing

function var setHangar(table_t squads)

Returns

nothing

function var setIcon(string icon)

Returns

nothing

function var setLocalPosition(Matrix matrix)

Returns

nothing

function var setNewName(string newName)

Returns

nothing

function var setOrderInfo(string info)

Returns

nothing

function var setPaymentTime(float timeSincePayDay)

Returns

nothing

function var setPlan(BlockPlan plan)

Returns

nothing

function var setReconstructionValue(double value)

Returns

nothing

function var setScriptValue(string key, var value)

Sets a custom value.

Parameters

key A string that serves as the name of the value
value The value to save. Must be bool, number, string or nil. If nil is given, the value will be deleted.

Returns

The previous value

function var setShieldPercentage(float percentage)

Returns

nothing

function var setStatusMessage(NamedFormat status)

Returns

nothing

function var setTitle(NamedFormat title)

Returns

nothing

function var setTorpedoes(table_t torpedoes)

Returns

nothing

Overview
Home Functions Search
Search:

This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.

Work in Progress. Documentation of Avorion Version: 2.5.7 c8e4beec84f7